package com.atguigu.gulimall.ware.dao;

import com.atguigu.gulimall.ware.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 商品库存
 * 
 * @author fangdada
 * @email 1819675707@qq.com
 * @date 2021-05-01 11:08:19
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {

	void addStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);

	/**
	 * 查询当前sku的总库存量
	 * @author fd
	 * @date 2021/7/1 15:51
	 * @param skuId
	 * @return long
	 */
	Long getSkuStock(Long skuId);

	/**
	 * @Author FangDaDa
	 * @Description TODO
	 * @Date 20:48 2021/9/6
	 * @Param [skuId]
	 * @return java.util.List<java.lang.Long>
	 **/
    List<Long> listWareIdHasSkuStock(Long skuId);

	/**
	 * 锁定库存
	 * @param skuId
	 * @param wareId
	 * @param num
	 * @return
	 */
	Long lockSkuStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("num") Integer num);

	/**
	 * 解锁库存
	 * @param skuId
	 * @param wareId
	 * @param num
	 */
	void unLockStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("num") Integer num);
}
